#ifndef ATTACHEDOBJECTUPDATER_H
#define ATTACHEDOBJECTUPDATER_H

#include "OGRE\OgreBone.h"
#include "BaseObject.h"
#include "boost\tuple\tuple.hpp"

typedef boost::tuple<Ogre::Node*, Ogre::Bone*, btTransform> BoneTuple;
typedef boost::tuple<BaseObjectPtr, btTransform> ObjectTuple;
typedef map<BaseObjectPtr, BoneTuple> BoneMap;
typedef map<BaseObjectPtr, ObjectTuple> ObjectMap;

class AttachedObjectUpdater
{
public:
	AttachedObjectUpdater(void);
	~AttachedObjectUpdater(void);
	void attachObjectToBone(BaseObjectPtr obj, Ogre::Node *node, Ogre::Bone* bone, btTransform &trans);
	void removeObject(BaseObjectPtr obj);
	void attachObjectToObject(BaseObjectPtr obj, BaseObjectPtr attachedTo, btTransform &trans);
	void updateObjects(void);
	void clearList(void);
private:
	BoneMap mBones;
	ObjectMap mObjects;
	Ogre::Quaternion getWorldOrientation(Ogre::Node *node, Ogre::Bone* bone);
	Ogre::Vector3 getWorldPosition(Ogre::Node *node, Ogre::Bone* bone);
	Ogre::Matrix4 getWorldTransformation(Ogre::Node *node, Ogre::Bone* bone);
};
typedef boost::shared_ptr<AttachedObjectUpdater> AttachedObjectUpdaterPtr;
#endif